package main

import (
	"encoding/json"
	"fmt"
)

type Server struct {
	Name string `json:"host"`
	IP   string `json:"address"`
	Port int
	safe bool
}

func main() {
	// serialize struct
	server := &Server{"localhost", "127.0.0.1", 8080, true}
	jsonCode,_:=json.Marshal(server)
    fmt.Println(string(jsonCode))
	// deserialize struct
	server2:=new(Server)
	json.Unmarshal(jsonCode,server2)
	fmt.Println(server2)
	// serialize map
	man:=map[string]interface{}{"Name":"Tom","Age":20}
	jsonCode2,_:=json.Marshal(man)
	fmt.Println(string(jsonCode2))
	// deserialize map
	man2:=make(map[string]interface{})
	json.Unmarshal(jsonCode2,&man2)
	fmt.Println(man2)
}